package com.dao.Impl;

import com.dao.jobDao;
import com.pojo.job;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.util.List;

/**
 * @Date :15:00 2021/5/25
 * @Author :xuhe
 */
public class jobImpl implements jobDao {
    private QueryRunner runner;
    public void setRunner(QueryRunner runner) {
        this.runner = runner;
    }
    @Override
    public List<job> findAll() {
        try {
            return runner.query("select job_name from javaweb",new BeanListHandler<job>(job.class));
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    @Override
    public job findJobByName(String job_name) {
        try {
            job_name = "%"+job_name+"%";
            return runner.query("SELECT * FROM javaweb where job_name LIKE ?",new BeanHandler<job>(job.class),job_name);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
